﻿Imports NUnit.Framework
Imports Microsoft.Activities.UnitTesting
Imports Microsoft.VisualBasic.Activities
Imports System.Activities.Expressions

Public Class TestSystem

    <Test()>
    Public Sub TestWMISYSBios()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetBios
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSComputerSystem()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetComputerSystem
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSComputerSystemProduct()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetComputerSystemProduct
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSDesktop()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDesktop
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSEventLog()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetEventLog With {
            .Condition = "TimeGenerated>='20120314000000.0+540'"}
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSInstalledSoftwares()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetInstalledSoftwares
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSOperatingSystem()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetOperatingSystem
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSProcess()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetProcess
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSService()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetService
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSUserAccount()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetUserAccount
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSPnPEntry()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetPnPEntry
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSPhisicalMemory()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetPhysicalMemory
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSDiskDrive()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDiskDrive
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSDiskPartition()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDiskPartition
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSPrinter()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetPrinter
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSNetworkAdapterConfiguration()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetNetworkAdapterConfiguration
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSAntiVirus()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetAntiVirusProduct With {
            .IsVistaLater = True}
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSAntiSpyWare()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetAntiSpywareProduct With {
            .IsVistaLater = True}
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSFirewall()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetFirewallProduct With {
            .IsVistaLater = True}
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSNetworkLoginProfile()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetNetworkLoginProfile
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity()

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <TestCase("SQLBrowser", 1)>
    <TestCase("SQLBrowser", 3)>
    <TestCase("SQLBrowser", 4)>
    <TestCase("SQLBrowser", 2)>
    Public Sub TestWMISYSSetServiceState(ByVal servicename As String, ByVal status As Integer)

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSSetServiceStatus With {
            .ServiceName = servicename, .Status = status}
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSGetLogicalDisk()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetLogicalDisk
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSGetDesktopMonitor()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDesktopMonitor
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSGetDsComputer()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDsComputer
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSGetDsUser()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDsUser
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    <Test()>
    Public Sub TestWMISYSGetDsPrinter()

        Dim testActivity As New KumaSystem.Activities.WMI.System.WMISYSGetDsPrinter
        Dim wfInvoker As New WorkflowInvokerTest(testActivity)

        wfInvoker.TestActivity(New TimeSpan(0, 5, 0))

        wfInvoker.AssertOutArgument.IsNotNull("Results", "結果が Null です。")
        OutputTestLog(wfInvoker)

    End Sub

    '<Test()>
    'Public Sub TestGetHashtableValue()

    '    Dim baseActivity As New System.Activities.Statements.Sequence
    '    Dim ht As New System.Activities.Variable(Of Hashtable)("hv") With {
    '       .Default = New VisualBasicValue(Of Hashtable)("New System.Collections.Hashtable")}
    '    baseActivity.Variables.Add(ht)
    '    Dim ret As New System.Activities.Variable(Of Object)("ret")
    '    baseActivity.Variables.Add(ret)

    '    Dim testActivity1 As New KumaSystem.Activities.WMI.SetHashtableValue With {
    '        .HashArgument = New VisualBasicReference(Of Hashtable)("hv"),
    '        .KeyName = "Key1",
    '        .Values = New VisualBasicValue(Of Object)(1)}
    '    Dim testActivity2 As New KumaSystem.Activities.WMI.SetHashtableValue With {
    '        .HashArgument = New VisualBasicReference(Of Hashtable)("hv"),
    '        .KeyName = "Key2",
    '        .Values = New VisualBasicValue(Of Object)(2)}
    '    Dim testActivity3 As New KumaSystem.Activities.WMI.GetHashtableValue With {
    '        .HashArgument = New VisualBasicValue(Of Hashtable)("hv"),
    '        .KeyName = "Key1",
    '        .Values = New VisualBasicReference(Of Object)("ret")}
    '    Dim testActivity4 As New System.Activities.Statements.WriteLine With {
    '        .Text = New VisualBasicValue(Of String)("ret.tostring")}

    '    baseActivity.Activities.Add(testActivity1)
    '    baseActivity.Activities.Add(testActivity2)
    '    baseActivity.Activities.Add(testActivity3)
    '    baseActivity.Activities.Add(testActivity4)

    '    Dim wfInvoker As New WorkflowInvokerTest(baseActivity)

    '    wfInvoker.TestActivity()

    'End Sub

#Region "結果出力 Output Log"
    Private Sub OutputTestLog(ByVal wfInv As WorkflowInvokerTest)
        For Each res As Hashtable In wfInv.OutArguments("Results")
            For Each resCol In res.Keys
                Dim resVal = res.Item(resCol)
                If resVal Is Nothing Then
                    Continue For
                    Console.WriteLine(resCol.ToString + ": Null")
                Else
                    Console.WriteLine(resCol.ToString + ":" + resVal.ToString)
                End If
            Next
        Next
    End Sub
#End Region

End Class
